<?php
/**
 * @name: init.php
 * @version: 1.0
 * @package: PHP MVC Framework
 * @uses: Includes base files
 * @copyright: MIT
 * @author Andrew Lowther
 */

// Define database variables
include library . 'config/config.class.php';

// Include the controller class
include library . 'application/controller_base.class.php';

// Include the stack
include library . 'application/stack.class.php';

// Include the registry
include library . 'application/registry.class.php';

// Include the router class
include library . 'application/router.class.php';

// Include the template class
include library . 'application/template.class.php';

// Auto load model classes
function __autoload($class) {

    // Get the file name from the directory structure
    $file = strtolower($class) . '.class.php';

    // Get the model file
    $dir = library . 'model/' . $file;

    // Check the file exists
    if (file_exists($dir)) {

        // If it does, include it
        include $dir;

    } else if ($stack = new Stack($class)) {

        

    } else {

        return false;

    }

}

// Create a new registry object
$registry = new Registry;

$registry->core = new RayCore;

// Create a database registry object
$registry->db = new RayDb;

// Create a session variable
$registry->session = new RaySession;

// Instantiate the helper
$registry->helper = new RayHelper;

?>
